package com.monad.firemoth.system.controller;

import com.monad.firemoth.common.utils.Result;
import com.monad.firemoth.system.entity.LoginParam;
import com.monad.firemoth.system.service.LoginService;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author 单C胞生物
 * @version 1.0.0
 * @date 2024/4/20 21:40
 * @description 登录 Controller
 */
@Tag(name = "登录")
@RestController
@RequestMapping("/system")
public class LoginController {

    @Autowired
    private LoginService loginService;

    @PostMapping("/login")
    public Result login(@RequestBody LoginParam loginParam, HttpServletRequest request) {
        return loginService.login(loginParam, request);
    }

    @PostMapping("/register")
    public Result register(@RequestBody LoginParam loginParam) {
        return loginService.register(loginParam);
    }

    @PostMapping("/logout")
    public Result logout() {
        return loginService.logout();
    }

}
